<html>
<head>
	<script type="text/javascript">
		var aJaxURL		= "server-side/view/transporter_company.action.php";		//server side folder url
		var tName		= "example";									//table name
		var fName		= "add-edit-form";								//form name
		
		$(document).ready(function (){
			LoadTable();
			GetButtons("add_button", "delete_button", "", "", "");			
			SetEvents("add_button", "delete_button", "check-all", tName, fName, aJaxURL);
		});
        
		function LoadTable(){
			GetDataTable(tName, aJaxURL, "get_list", 3, "", 0, "");
		}
		
		function LoadDialog(){
	    	$("#check_rs").button().click(function(){
	    	    ajax            =   {};   
                ajax.url        =   "server-side/wsdl/invoice.action.php";
                ajax.data       =   {};    
    	        ajax.data.act   =    'save_client';
    	        ajax.data.ri    =    $("#code").val();                              
                ajax.success    =    function(data) {
                   $("#name").val(data.mesage)
				
		    }  
	    	$.ajax(ajax); 
	    	});

			GetDialog(fName, 590, "auto", "");
		}
				
	    // Add - Save
	    $(document).on("click", "#save-dialog", function () {
	    	param = new Object();
	    	param.act	= "save";
	    	param.id    = rID;
	    	param.code	= $("#code").val();
	    	param.name	= $("#name").val();	
			if(param.code == ""){
				alert("შეავსეთ  კოდი!");
			}else if(param.name == ""){
				alert("შეავსეთ  დასახელება!");			
			}else {
			    $.ajax({
			        url: aJaxURL,
				    data: param,
			        success: function(data) {
				        if(typeof(data.error) != "undefined"){
							if(data.error != ""){
								alert(data.error);
							}else{
								LoadTable();
					        	CloseDialog(fName);
							}
						}
				    }
			    });
			}
		});	

        
/* 		$(document).on("keydown", "#code", function (event) {
			if (event.keyCode == $.ui.keyCode.ENTER){
            	$("#part_number").focus();
				event.preventDefault();					//Clear Dialog Default <b>keypress<b> Event
            }
		}); */
    </script>
</head>

<body>
    <div id="dt_example" class="ex_highlight_row">
        <div id="container">
            <div id="dynamic">
            	<h2 align="center">პროდუქტები</h2>
	        	<div id="button_area">
	        		<button id="add_button">დამატება</button><button id="delete_button">წაშლა</button>
	        	</div>
                <table class="display" id="example">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>                            
                            <th style="width: 368px">დასახელება</th>
                            <th class="min">საიდენთიიკაციო</th>
                            <th class="check">#</th>
                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_code" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_name" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                            	<input type="checkbox" name="check-all" id="check-all">
                            </th>
                        </tr>
                    </thead>
                </table>	
            </div>
        </div>
    </div>
    
    <!-- jQuery Dialog -->
    <div id="add-edit-form" class="form-dialog" title="პროდუქტები">
    	<!-- aJax -->
	</div>
	
    <!-- jQuery Dialog -->
    <div id="image-form" class="form-dialog" title="პროდუქციის სურათი">
    	<img id="view_img" src="media/uploads/images/production/0.jpg">
	</div>
</body>
</html>